﻿@{
    ViewBag.Title = " 用户列表";
    //Layout = "~/Views/Shared/_Layout_Easyui.cshtml";
    Layout = null;
}
<div id="user_list_create_window"></div>
<div id="user_list_login_window"></div>

<script type="text/javascript">
    Oneworks.CreatePage('UserList', {
        settings: {
            createpage: '/User/List'
        },
        controls: {
            createwindow: $('#user_list_create_window'),
            loginwindow: $('#user_list_login_window')
        },
        events: {
            onLoadCreate: function () {
                var page = Oneworks.page, create = page['UserCreate'], list = page['UserList'];
                create.events.onClose = list.events.onCloseCreate;
                create.events.onSuccess = list.events.onCreateSuccess;
                create.events.onFailure = list.events.onCreateFailure;
            },
            onOpenCreate: function () {
                Oneworks.page['UserList'].controls.createwindow.window('open');
            },
            onCloseCreate: function () {
                Oneworks.page['UserList'].controls.createwindow.window('close');
            },
            onCreateSuccess: function () {
                console.log(arguments[0]);
                Oneworks.Easyui.alert(arguments[0].Message, function () {
                    Oneworks.Easyui.alert(arguments[0].Result.UserCode);
                });
            },
            onCreateFailure: function () {
                Oneworks.Easyui.alert(arguments[0].Message);
            },
            onLoadLogin: function () {
                var page = Oneworks.page, create = page['UserLogin'], list = page['UserList'];
                create.events.onClose = list.events.onLoginClose;
                create.events.onSuccess = list.events.onLoginSuccess;
                create.events.onFailure = list.events.onLoginFailure;
            },
            onLoginSuccess: function () {
                Oneworks.Easyui.alert('登录成功');
                Oneworks.page['UserList'].controls.loginwindow.window('close');
            },
            onLoginFailure: function () {
                Oneworks.Easyui.alert(arguments[0].Message);
            },
            onLoginClose: function () {
                Oneworks.page['UserList'].controls.loginwindow.window('close');
            },
            onLoginOpen: function () {
                Oneworks.page['UserList'].controls.loginwindow.window('open');
            }
        },
    }, function () {
        var that = this,
            controls = that.controls,
            settings = that.settings,
            events = that.events;
        controls.init = function () {
            controls.createwindow.Easyui().window({
                title: '账户创建',
                width: 460,
                height: 400,
                href: '/User/create',
                closed: true,
                onLoad: events.onLoadCreate
            });
            controls.loginwindow.Easyui().window({
                title: '用户登录',
                width: 400,
                height: 200,
                href: '/User/Login',
                closed: true,
                onLoad: events.onLoadLogin
            });
        };

        events.init = function () {
        };
        controls.init();
        events.init();
        controls.createwindow.window('open');
    });
</script>

